<template>
    <div>
        <h2>修改</h2>
        <div class="box">
            <el-form
                ref="ruleFormRef"
                :model="data"
                
                class="demo-ruleForm"
                :size="formSize"
                status-icon>
                <el-form-item  label="地址" prop="name">
                    <el-input v-model="data.name" />
                </el-form-item>   
                <el-form-item>
                    <el-button @click="back()">取消</el-button>
                    <el-button type="primary" @click="getAddform">确定</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script setup lang="ts">
import { reactive, ref,toRefs,onMounted } from "vue";
import  {FormInstance, FormRules,ElMessage } from "element-plus";
import { addressAdd } from "../../api/track/index";
import { Message } from "@element-plus/icons-vue";
import router from "../../router/router";
import { useRoute} from "vue-router";



// 接收跳转过来的值
const route=useRoute()
onMounted(() => {
    console.log('接收跳转过来的值',route.query);
    
})


const ruleFormRef = ref<FormInstance>()
const data:any=reactive({
    id:0,
    name:route.query.name
   
})
// data.id=route.query.id
// data.name=route.query.name
// const{addform}=toRefs(data)
const formSize = ref('default')


// 修改
const getAddform=async ()=>{
    // console.log('添加');
    // const data={id:data.id}
    let res:any= await addressAdd(data)
    console.log(res);
    
    if(res.code==='00000'){
        ElMessage({
            message: "添加成功",
            type: "success",
        });
        router.push('/listView/point') 
    }    
}
// 取消
const back=()=>{
    router.push('/listView/point')
}
</script>

<style scoped>
.box{
    width: 300px;
    margin: 30px;
}
</style>